class SlowMove {
	animationList = []
	start = []
	curr = []
	timer = null
	running = false
	num = 1
	dim = 1
	speed = 3 // 0 ~ 10
	constructor(options) {
		this.init(options)
	}
	init(options){
		Object.assign(this,options)
		this.dim = this.num
		for(let i=0; i<this.dim; i++){
			this.curr[i] = 0
			if(this.start[i]){
				this.curr[i] = this.start[i]
			}
		}
	}
	move(...args){
		var m = () => {
			if(!this.timer){
				this.running = true
				let end = this.animationList.shift()
				let step = []
				this.timer = setInterval(()=>{
					let stop = true
					for(let i=0; i<this.dim; i++){
						step[i] = (end[i] - this.curr[i]) * this.speed / 20
						this.curr[i] += step[i]
						if(Math.abs(step[i]) > .1){
							stop = false
						}
					}
					this.handler(this.curr)
					if(stop){
						clearInterval(this.timer)
						this.timer = null
						this.stepFinish()
						if(this.animationList.length !== 0){
							this.curr = end
							m()
						}else{
							this.running = false
							this.allFinish()
						}
					}
				},16)
			}
		}
		this.animationList.push(args)
		m()
	}
	// hooks
	handler(){}
	stepFinish(){}
	allFinish(){}
}